﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace auxiliary_proj
{
    public partial class FormPOSummary : Form
    {
        String po_number;
        String vendor;
        String date;
        String createdBy;

        public FormPOSummary()
        {
            InitializeComponent();
        }
        public FormPOSummary(String po_number, String vendor, String date, String createdBy) {
            InitializeComponent();
            this.lbl_created.Text = "" + createdBy;
            this.lbl_po_order_no.Text = "" + po_number;
            this.lbl_vendor.Text = "" + vendor;
            this.lbl_date_made.Text = "" + date;
            this.po_number = po_number;
            this.vendor = vendor;
            this.createdBy = createdBy;
            this.date = date;
            qPOOrderSummary();
        }
        public void qPOOrderSummary() 
        {
            string query = "select i.vendorCode as vendor_code, i.item_id as item_id, i.description as description, po.quantity as quantity, po.price as price from purchase_order as  p, po_item as po, item as i where p.po_number=po.po_number and po.item_id=i.item_id and p.po_number='" + po_number + "'";
            try
            {
                POOrderSummaryDGV.DataSource = Query.select(query);
            }
            catch (MySqlException exc) { MessageBox.Show(exc.Message); }
        }
    }
}
